package cqrtplm.config;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import cqrtplm.dto.ImportDocumentDTO;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Getter
@Slf4j
@Component
public class ProcessDocumentConfig extends AnalysisEventListener<ImportDocumentDTO> {

    private final List<ImportDocumentDTO> dataList = new ArrayList<>();

    @Override
    public void invoke(ImportDocumentDTO data, AnalysisContext context) {
        dataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        // 全部解析完毕
        log.info("共读取条数: {}", dataList.size());
    }

}
